Shop (Deed Building)/Technical
The information on this page is based on Elona 1.22's source code. Any changes in Elona+ will not be reflected. Whenever the game clock in Elona strikes midnight, all player-owned shops undergo a single "shop turn". The shop turn is when the shop actually determines sales, income, and items gained. This page is a technical explanation of how this shop turn works. For each shop, the following process is run: *If the shop does not have a shopkeeper, display "You don't have a shopkeeper." and immediately exit. *Calculate 100 - the player's current Shop Rank (as seen in the player journal). This is the shop "level". For example, a Shop Rank of 70 would correspond to a level of 30. *Determine the number of customers who visit the shop with the following process: **3 times, add a random number from 0 to the \frac{Shop Level}{3} + 5 to the total number of potential customers. **Multiply the customer count by \frac{80 + Shopkeeper Charisma * \frac{3}{2}}{100} **If there would be 0 customers, set the customer count to 1. *At this point, determine the list of items that can be sold. This will be any item in the shop except the following: **Shop Strongboxes **Registers **Books **Gold **Shelters **Deeds **Any item weighing less than 0s **Any unique item **Any item whose raw value is < 50 **Furniture *At this point the shop determines actual sales. It will run the following loop as many times as customers were determined above: **If there are no items available for sale, stop **Pick a random item available for sale and calculate a sale value: ***Determine the item's basic value (based on item ID, material, modifiers, etc) ***Multiply the value by \frac{\left(10 + \sqrt{Shopkeeper Negotiation * 200} \right)}{100} **Determine if the item is sold ***If the calculated sale value is < 1, it is not sold ***If a random number from 0 to the calculated value is > the shop level * 100 + 500, it is not sold (presumably, the customer considers it too expensive) ***If the item quantity is somehow 0, it is not sold (nothing to sell) ***If a random number from 0 to 8 is 0, it is not sold (random chance of failure) **At this point, the sale is finalized. A random number of the available quantity of that item will be sold (not necessarily all!) by subtracting the quantity available and multiplying the calculated value as appropriate. A random number from 0 to 4 is chosen ***If the number is 0, add the item type and calculated value to a list of items to generate ***Otherwise, add the calculated value to the total income for this shop turn *Once the above loop finishes, the shop will handle actual income. **The total income for this shop turn is added directly to the shop strongbox. **For each entry in the list of items to generate in the above loop, generate appropriate items (same type, same total value) and add to the strongbox *If no items were sold, the player will receive the message "count customers visited your shop but shopkeeper couldn't sell any item." *If items were sold: **The player will receive the message "count customers visited your shop and shopkeeper sold count items. shopkeeper put count gold and count items in the shop strong box." **The shopkeeper will gain negotiation experience. The basic formula is 6 * \sqrt{Income} with a minimum cap of 25 and a maximum cap of 1000. **If the number of items sold > \frac{110 - Shop Rank}{10} then the game will grant points toward advancing to the next rank. See Ranking Mechanics Note that each run of this process is independent. If the player has multiple shops then each will be run individually. The result is that if the first shop causes a rank change it will be reflected in the second shop's "turn". Category:Technical information